home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / zindent7.zip / ZINDENT7.PAS < prev    next >
Pascal/Delphi Source File  |  1987-03-30  |  12KB  |  407 lines

  1. (*<<<>>>*)
  2.  
  3. (*******************************************************************)
  4. (**)                                                             (**)
  5. (**)                PROGRAM     ZINDENT ;                        (**)
  6. (**)                                                             (**)
  7. (*******************************************************************)
  8.  
  9. CONST
  10.  
  11. SysTitle    =
  12. 'zINDENT.PAS, v. 7.D, Indent for dBASE / Turbo Pascal Source Files';
  13.  
  14. SysVersion1 = 'Command via : Line / File / User';
  15.  
  16. SysVersion2 = 'MSDOS version 0300pm, mon, 30.Mar.87, Glen Ellis';
  17.  
  18. SysCredit   = 'Apple/CPM  and  MSDOS  tested.            ';
  19.  
  20. SysPgmName  = 'ZINDLIST.DAT';  (* file containing filename list *)
  21.  
  22. SysCpuSpeed = 2 ; (* author's writing/developmental system is 2 MHz ! *)
  23.  
  24. (* parameters FOR Compiler *)
  25. {$C+}
  26. {$U+} (* $U+ User Interrupt benchmarks almost same as $U- *)
  27. {$F4}
  28.  
  29. (* parameters FOR LISTT.PAS, Borland's advanced Lister program *)
  30. {.U+}
  31. {.N-}
  32. {.P-}
  33. {.PO0}
  34.  
  35.  
  36. (*####################################################################*)
  37.  
  38. (*$I c:zinVAR.INC*) (* for core program *)
  39. (*$I C:zinSTR.INC*) (* required string utilties *)
  40. (*$I C:zinSCR.INC*) (* screen display procedures *)
  41. (*$I C:zinDOC.INC*) (* system documentation / readme.inc *)
  42. (*   C:ZReadme.INC*) (* not Pascal include file *)
  43. (*$I C:zinUTL.INC*) (* miscelaneous procedures *)
  44. (*$I C:zinDSK.INC*) (* disk file procedures *)
  45. (*$I C:zinKEYDB.INC*)  (* keyword dBASE *)
  46. (*$I C:zinKEYTP.INC*)  (* keyword Pascal *)
  47.  
  48.  
  49. (********************************************************************)
  50.  
  51.  
  52. BEGIN (*  MAIN  *)
  53.  
  54.    (*=======> INIT <=======*)
  55.  
  56.    (* programmer's options *)
  57.  
  58.    SysDisplay    := true  ;    (* always true   *)
  59.  
  60.    SysUserTrace  := true  ;    (* normal : display program path *)
  61.  
  62.    SysPgmTrace   := false ;    (* audit developmental path *)
  63.  
  64.    SysSpcTrace   := false ;    (* special, temporary *)
  65.  
  66.    (* name/function of procedure *) (* located in this file *)
  67.    (*                            *) (*                      *)
  68.    pSayHeader; (* Display header *) (* SysScr.inc           *)
  69.  
  70.    IF not SysPgmTrace then pDelay2;
  71.  
  72.    (*=======> FETCH <=======*)
  73.  
  74.    (* initz *)
  75.    SysPgmMod     := '  '  ;
  76.  
  77.    (* fetch command line from either paramstring or paramfile
  78.    (* set defaults for operational vars :
  79.    (*   Filename, Indent, Comment, LineCount, Vertiate
  80.    *)
  81.  
  82.    (* set mode flags true *)
  83.    (* ZinLine.Inc will re-assign *)
  84.    SysCmdLine := true ; (* enable Command Line Parse *)
  85.    SysCmdFile := false; (* file names via text file  *)
  86.    SysCmdUser := false; (* direct keyboard entry     *)
  87.  
  88.    (* parameter flags : if satisfied, then lower flag *)
  89.    SysCmdUserFile := false ;  (*  filename fetch *)
  90.    SysCmdUserParm := false ;  (*  parameter fetch *)
  91.  
  92.    (*=======> FETCH LINE ENTRY *)
  93.  
  94.    IF SysCmdLine then
  95.    begin
  96.  
  97.       IF SysPgmTrace then
  98.       begin
  99.          writeln; writeln;
  100.          writeln('--> SysCmdLINE');
  101.          pDelay1;
  102.       end;
  103.  
  104.       (*$I c:zinLINE.INC*) (*:::*)
  105.  
  106.       (* if user entered no command line, or requested Docs, then *)
  107.       (* pause while he reads header *)
  108.       If (SysInFileName = '?') then
  109.       begin
  110.          writeln; writeln;
  111.          writeln('User Entry / Documentation has been enabled . . . .');
  112.          pKeyPressed;
  113.       end;
  114.  
  115.    end;
  116.  
  117.    (*=======> FETCH FILE ENTRY *)
  118.  
  119.    IF SysCmdFile then
  120.    begin
  121.       IF SysPgmTrace then
  122.       begin
  123.          writeln('---> SysCmdFILE');
  124.          pDelay1;
  125.       end;
  126.       SysInFileName := SysPgmName;  (* read data file name *)
  127.       (*$I c:zinFILE.INC*) (*:::*)
  128.    end;
  129.  
  130.    (*=======> FETCH USER ENTRY *)
  131.  
  132.    IF ( (SysCmdUser) and (SysCmdUserFile) )
  133.    or
  134.       ( (SysCmdUser) and (SysCmdUserparm) )
  135.    then
  136.    begin
  137.       IF SysPgmTrace then
  138.       begin
  139.           writeln('---> SysCmdUSER');
  140.           pDelay1;
  141.       end;
  142.       (*$I c:zinUSER.INC*) (*:::*)
  143.    end;
  144.  
  145.    (*=======> CORE CONTROLLER <=======*)
  146.  
  147.    (* if filename and parameters installed *)
  148.    IF (SysCmdLine) or (SysCmdFile) or (SysCmdUser)
  149.       then SysEnableCORE := true
  150.    ELSE SysEnableCORE := false;
  151.  
  152.    IF SysUserTrace  then (* display list of file names *)
  153.    begin
  154.       writeln('SysUserTrace enabled');
  155.       pSayFileList; (*::: SysUtl.INC *)
  156.    end;
  157.  
  158.    IF SysPgmTrace then
  159.    begin
  160.       pSaySysVar;  (* big VAR display prior to CORE *)
  161.    end;
  162.  
  163.    (*=======> CORE <=======*)
  164.  
  165.    IF SysEnableCore then
  166.    begin
  167.  
  168.       IF SysPgmTrace then
  169.       begin
  170.          writeln('--- Enable Core ---');
  171.          pDelay1;
  172.       end;
  173.  
  174.       (* init : cmdline/cmdfile/cmduser *)
  175.       IF (SysInSourceMax = 0)
  176.          then SysInSourceMax := 1;
  177.  
  178.       (*=========================================*)
  179.       FOR SysInSourceCnt := 1 to SysInSourceMax do
  180.       begin  (* Count Through InSource Array of FileNames *)
  181.  
  182.          (* fetch new filename *)
  183.          (* parse for .typ *)
  184.          (* start file *)
  185.          (* read loop *)
  186.  
  187.          (* load the carrier memvar *)
  188.          SysInFileName := SysInSource[SysInSourceCnt];
  189.  
  190.          writeln('FileName : ', SysInFileName,' :');
  191.          pDelay1;
  192.  
  193.          (*=======> Parse file.typ for mode : OL, DB, TP *)
  194.  
  195.          (*:::*)
  196.          (* can be preset (forced) by user in SysUser.Inc. *)
  197.          (* default entry is '  '. *)
  198.  
  199.          if (SysPgmMod = '  ') then
  200.          begin
  201.  
  202.             pSysParse( SysInFileName, SysPgmMod, SPMSL, SPMSR );
  203.             (*::: SysDsk.INC *)
  204.  
  205.          (* IF SysPgmTrace then *)
  206.          (* begin               *)
  207.                writeln('Results of FileName Parse :',SysPgmMod,':');
  208.                pDelay1;
  209.          (* end; *)
  210.  
  211.          end;
  212.  
  213.          (*=======> Start Files *)
  214.  
  215.          (* create  three file.type vars for  .BAK, .(source), .$$$
  216.          (*         Open, Reset, Rewrite files *)
  217.          IF SysPgmTrace then
  218.          begin
  219.             writeln;
  220.             writeln('--- Start Files ---');
  221.             pDelay1;
  222.          end;
  223.  
  224.          SysIOcheck := true ; (* any one dead file will skip loop one time ! *)
  225.  
  226.          pSysStartFiles(SysIOcheck);  (*::: SysUtl.INC *)
  227.  
  228.          (*---------------*)
  229.          IF SysIOcheck then
  230.          begin
  231.  
  232.             IF SysUserTrace then
  233.             begin
  234.                writeln;
  235.                writeln('--- Start Read Loop --- ',SysInFileName);
  236.                pDelay1;
  237.             end;
  238.  
  239.             (* prep for linecnt during WHILE loop *)
  240.             SysLineNum := 0;
  241.  
  242.             (* operational var set to zero *)
  243.             pSysLvlInit;  (*::: SysUtl.INC *)
  244.  
  245.             (*=======> Scan Through File *)
  246.  
  247.             WHILE not (eof(SysInFile))
  248.             do
  249.             begin
  250.  
  251.                (* read text line from input file *)
  252.                readln(SysInFile,SysInLine);
  253.  
  254.                (* assign output string to value read in *)
  255.                SysOutLine := SysInLine;
  256.  
  257.                (* writing parms are long for indentifiability *)
  258.                (* procedure parms are small so line will be < 127 *)
  259.  
  260.                (* update short vars *)
  261.                pSysVarShortUPdt; (*::: SysUtl.INC *)
  262.  
  263.                (*===================================================
  264.                (*
  265.                (* current KeyWord module application flow:
  266.                (*
  267.                (* identify   KEYWORD,    and adjust indent
  268.                (* SysUserTrace start/stop of structures
  269.                (* toggle sysmarkwrite
  270.                (* OutSTR = exit line
  271.                (* indentPOS = current left margin position
  272.                (* indentNUM = actual indent group length
  273.                (* lineMAX   = max length of text line = 79
  274.                (* markWRITE = enable comments write to disk
  275.                (**)
  276.  
  277.                (*
  278.                (*   Indent for dBASE-II
  279.                (**)
  280.  
  281.                IF SysPgmMod = 'DB'
  282.                then
  283.                pKEYDB( SOLL, SIP, SIN, SLM, SMW, SLI, SLC, SLW);
  284.                (*::: KeyDB.INC*)
  285.  
  286.                (*
  287.                (*   Indent for Turbo Pascal
  288.